package com.example.bank.util;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import javax.management.Query;
import javax.servlet.http.HttpServletRequest;
import java.lang.management.ManagementFactory;
import java.net.InetAddress;
import java.util.Set;

/**
 * @author ：Leeziqiang
 * @description：TODO
 * @date ：2021/12/19 9:00
 */
public class IpAddressUtil {

    public static String PathAddress() {
        String strResult = "";
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder
                .getRequestAttributes()).getRequest();

        StringBuffer strBuf = new StringBuffer();
        strBuf.append(request.getScheme() + "://");
        strBuf.append(request.getServerName() + ":");
        strBuf.append(request.getServerPort() + "");
        strBuf.append(request.getContextPath() + "/");
        strResult = strBuf.toString();// +"FHADMINM/";//加入项目的名称
        return strResult;
    }
}
